package com.learn.project2.controller.wx.address;

import com.learn.project2.bean.MarketAddress;
import com.learn.project2.model.bo.wx.adress.AddressDeleteBO2;
import com.learn.project2.model.bo.wx.adress.AddressSaveBO2;
import com.learn.project2.model.vo.wx.address.AddressListVO2;

import com.learn.project2.service.wx.address.AddressService2;
import com.learn.project2.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:  收获地址
 * @author 亓永杰
 * @date 2022-01-09 23:10
 * @version 1.0
 */
@RestController
@RequestMapping("wx/address")
public class AddressController2 {


    @Autowired
    AddressService2 addressService2;

    @RequestMapping("list")
    public Result list(){

        AddressListVO2 addressListVO2 = addressService2.selectList();
        return Result.ok(addressListVO2);
    }
/**
 * @description: 获取地址的详细信息
 * @param:
 * @return:
 * @author 亓永杰
 * @date: 2022-01-10 23:58
 */
    @RequestMapping("detail")
    public Result detail(Integer id){
        MarketAddress address = addressService2.detail(id);
        return Result.ok(address);
    }
/** 
 * @description: 保存收货地址(添加和编辑)
 * @param:  
 * @return:  
 * @author 亓永杰
 * @date: 2022-01-11 09:50
 */ 
    @RequestMapping("save")
    public Result save(@RequestBody AddressSaveBO2 addressSaveBO2){
        int id = addressService2.save(addressSaveBO2);
        return Result.ok(id);
    }
/** 
 * @description: 删除收货地址（逻辑删除）
 * @param:
 * @return:  
 * @author 亓永杰
 * @date: 2022-01-11 09:50
 */ 
    @RequestMapping("delete")
    public Result delete(@RequestBody AddressDeleteBO2 addressDeleteBO2){
        addressService2.delete(addressDeleteBO2.getId());
        return Result.ok();
    }
}
